package com.jxaummd.mushroom.main.common.fragment;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.RelativeLayout;

import com.jxaummd.mushroom.R;
import com.jxaummd.mushroom.R2;
import com.jxaummd.mushroom.core.app.activity.ActivityManager;
import com.jxaummd.mushroom.core.base.fragment.PresenterFragment;
import com.jxaummd.mushroom.core.util.ui.status.StatusBarCompat;
import com.jxaummd.mushroom.main.common.contract.LaunchContract;
import com.jxaummd.mushroom.main.common.presenter.LaunchPresenter;

import butterknife.BindView;
import butterknife.OnClick;
import me.yokeyword.fragmentation.ISupportFragment;

public class LaunchFragment extends PresenterFragment<LaunchContract.Presenter>
        implements LaunchContract.View {

    //倒计时view
    @BindView(R2.id.ec_actv_common_launch_timer)
    AppCompatTextView mTextTimer = null;

    @BindView(R2.id.ec_rl_common_launch_bg)
    RelativeLayout mRelativeLayout = null;

    @OnClick(R2.id.ec_actv_common_launch_timer)
    public void clickTimer(){
        mPresenter.skipTimer();
    }


    @Override
    protected LaunchContract.Presenter initPresenter() {
        return new LaunchPresenter(this, getContext());
    }

    @Override
    public Object setLayout() {
        return R.layout.common_launch;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        mPresenter.start();
    }

    @Override
    public void updateTimer(String message) {
        if (mTextTimer != null)
            mTextTimer.setText(message);
    }

    @Override
    public void changeBackGround(Drawable drawable) {
        mRelativeLayout.setBackground(drawable);
    }

    @Override
    public void setNoStatusBar() {
        StatusBarCompat.setFullScreen(getProxyActivity(), StatusBarCompat.STATUEBAR_FULLSCREEN);
    }

    @Override
    public void startFragment(ISupportFragment fragment) {
        startWithPop(fragment);
    }

    @Override
    public void startActivity() {
        Intent intent = new Intent(getProxyActivity(), ActivityManager.getActivity("main"));
        startActivity(intent);
        getProxyActivity().finish();
    }
}
